<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>emp-toolkit: /Users/wangxiao/git/emp-toolkit/emp-tool/io/check_io_channel.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo-full-doxygen.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">emp-toolkit
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('check__io__channel_8h_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">check_io_channel.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="check__io__channel_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef CHECK_IO_CHANNEL_H__</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define CHECK_IO_CHANNEL_H__</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#include &lt;iostream&gt;</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="net__io__channel_8h.html">net_io_channel.h</a>&quot;</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="keyword">using namespace </span><a class="code" href="namespacestd.html">std</a>;</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;</div><div class="line"><a name="l00013"></a><span class="lineno"><a class="line" href="class_check_i_o.html">   13</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_check_i_o.html">CheckIO</a>: <span class="keyword">public</span> <a class="code" href="class_i_o_channel.html">IOChannel</a>&lt;CheckIO&gt; { <span class="keyword">public</span>:</div><div class="line"><a name="l00014"></a><span class="lineno"><a class="line" href="class_check_i_o.html#a45b19f808011f05325614f2efa609175">   14</a></span>&#160;    <a class="code" href="class_net_i_o.html">NetIO</a> * <a class="code" href="class_check_i_o.html#a45b19f808011f05325614f2efa609175">netio</a>;</div><div class="line"><a name="l00015"></a><span class="lineno"><a class="line" href="class_check_i_o.html#a409791dc21f3f0977363a5c8f3270a98">   15</a></span>&#160;    <span class="keywordtype">bool</span> check_result = <span class="keyword">true</span>;</div><div class="line"><a name="l00016"></a><span class="lineno"><a class="line" href="class_check_i_o.html#ad27950b171bbb070e2e10881d2c4ce9c">   16</a></span>&#160;    <span class="keywordtype">char</span> * buffer = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l00017"></a><span class="lineno"><a class="line" href="class_check_i_o.html#ac31b4c137a1830e7b1cbed11d22212c9">   17</a></span>&#160;    <span class="keywordtype">char</span> * net_buffer = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l00018"></a><span class="lineno"><a class="line" href="class_check_i_o.html#a61e414d30613e4a56de9ae5b1fa0f7e7">   18</a></span>&#160;    <span class="keywordtype">int</span> check_size = 0;</div><div class="line"><a name="l00019"></a><span class="lineno"><a class="line" href="class_check_i_o.html#ab65699a564c4eaafc41467f45fd3e7c9">   19</a></span>&#160;    <a class="code" href="class_check_i_o.html#ab65699a564c4eaafc41467f45fd3e7c9">CheckIO</a>(<a class="code" href="class_net_i_o.html">NetIO</a> * netio ) {</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;        this-&gt;netio = netio;</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;        buffer = <span class="keyword">new</span> <span class="keywordtype">char</span>[<a class="code" href="config_8h.html#a990a828773d37e2ca5756a9f585a07f6">CHECK_BUFFER_SIZE</a>];</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;        net_buffer = <span class="keyword">new</span> <span class="keywordtype">char</span>[<a class="code" href="config_8h.html#a990a828773d37e2ca5756a9f585a07f6">CHECK_BUFFER_SIZE</a>];</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;    }</div><div class="line"><a name="l00024"></a><span class="lineno"><a class="line" href="class_check_i_o.html#a6f12175200211be966e8dd27aa650162">   24</a></span>&#160;    <a class="code" href="class_check_i_o.html#a6f12175200211be966e8dd27aa650162">~CheckIO</a>(){</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;        <span class="keyword">delete</span>[] buffer;</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;        <span class="keyword">delete</span>[] net_buffer;</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;    }</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;</div><div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="class_check_i_o.html#aaf5dd59dbbd7aa89eed7889b9eb3f2aa">   29</a></span>&#160;    <span class="keywordtype">bool</span> <a class="code" href="class_check_i_o.html#aaf5dd59dbbd7aa89eed7889b9eb3f2aa">get_check_result</a>() {</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;        netio-&gt;<a class="code" href="class_i_o_channel.html#aecdc2e6d7e95d96d346c63fc57e5b4eb">recv_data</a>(net_buffer, check_size);</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;        check_result &amp;= (strncmp(net_buffer, buffer, check_size)==0);</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;        check_size = 0;</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;        <span class="keywordflow">return</span> check_result;</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;    }</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;</div><div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="class_check_i_o.html#af1baac326866563f438fa4384b2c10af">   37</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="class_check_i_o.html#af1baac326866563f438fa4384b2c10af">recv_data_impl</a>(<span class="keywordtype">void</span>  * data, <span class="keywordtype">int</span> len) {</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;    }</div><div class="line"><a name="l00039"></a><span class="lineno"><a class="line" href="class_check_i_o.html#ad218a7998875112dffff7dc8a67b5203">   39</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="class_check_i_o.html#ad218a7998875112dffff7dc8a67b5203">send_data_impl</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> * data, <span class="keywordtype">int</span> len) {</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;        assert(len &lt; <a class="code" href="config_8h.html#a990a828773d37e2ca5756a9f585a07f6">CHECK_BUFFER_SIZE</a>);</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;        <span class="keywordflow">if</span>(check_size + len &gt;= <a class="code" href="config_8h.html#a990a828773d37e2ca5756a9f585a07f6">CHECK_BUFFER_SIZE</a>) {</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;            netio-&gt;<a class="code" href="class_i_o_channel.html#aecdc2e6d7e95d96d346c63fc57e5b4eb">recv_data</a>(net_buffer, check_size);</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;            check_result &amp;= (strncmp(net_buffer, buffer, check_size)==0);</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;            check_size = 0;</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;        }</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;        memcpy(buffer+check_size, data, len);</div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;        check_size += len;</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    }</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;};</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;<span class="preprocessor">#endif//CHECK_IO_CHANNEL</span></div><div class="ttc" id="class_check_i_o_html_aaf5dd59dbbd7aa89eed7889b9eb3f2aa"><div class="ttname"><a href="class_check_i_o.html#aaf5dd59dbbd7aa89eed7889b9eb3f2aa">CheckIO::get_check_result</a></div><div class="ttdeci">bool get_check_result()</div><div class="ttdef"><b>Definition:</b> check_io_channel.h:29</div></div>
<div class="ttc" id="class_i_o_channel_html_aecdc2e6d7e95d96d346c63fc57e5b4eb"><div class="ttname"><a href="class_i_o_channel.html#aecdc2e6d7e95d96d346c63fc57e5b4eb">IOChannel::recv_data</a></div><div class="ttdeci">void recv_data(void *data, int nbyte)</div><div class="ttdef"><b>Definition:</b> io_channel.h:17</div></div>
<div class="ttc" id="class_check_i_o_html_ad218a7998875112dffff7dc8a67b5203"><div class="ttname"><a href="class_check_i_o.html#ad218a7998875112dffff7dc8a67b5203">CheckIO::send_data_impl</a></div><div class="ttdeci">void send_data_impl(const void *data, int len)</div><div class="ttdef"><b>Definition:</b> check_io_channel.h:39</div></div>
<div class="ttc" id="config_8h_html_a990a828773d37e2ca5756a9f585a07f6"><div class="ttname"><a href="config_8h.html#a990a828773d37e2ca5756a9f585a07f6">CHECK_BUFFER_SIZE</a></div><div class="ttdeci">#define CHECK_BUFFER_SIZE</div><div class="ttdef"><b>Definition:</b> config.h:9</div></div>
<div class="ttc" id="namespacestd_html"><div class="ttname"><a href="namespacestd.html">std</a></div></div>
<div class="ttc" id="class_net_i_o_html"><div class="ttname"><a href="class_net_i_o.html">NetIO</a></div><div class="ttdef"><b>Definition:</b> net_io_channel.h:22</div></div>
<div class="ttc" id="net__io__channel_8h_html"><div class="ttname"><a href="net__io__channel_8h.html">net_io_channel.h</a></div></div>
<div class="ttc" id="class_check_i_o_html"><div class="ttname"><a href="class_check_i_o.html">CheckIO</a></div><div class="ttdef"><b>Definition:</b> check_io_channel.h:13</div></div>
<div class="ttc" id="class_check_i_o_html_a6f12175200211be966e8dd27aa650162"><div class="ttname"><a href="class_check_i_o.html#a6f12175200211be966e8dd27aa650162">CheckIO::~CheckIO</a></div><div class="ttdeci">~CheckIO()</div><div class="ttdef"><b>Definition:</b> check_io_channel.h:24</div></div>
<div class="ttc" id="class_i_o_channel_html"><div class="ttname"><a href="class_i_o_channel.html">IOChannel</a></div><div class="ttdef"><b>Definition:</b> io_channel.h:12</div></div>
<div class="ttc" id="class_check_i_o_html_ab65699a564c4eaafc41467f45fd3e7c9"><div class="ttname"><a href="class_check_i_o.html#ab65699a564c4eaafc41467f45fd3e7c9">CheckIO::CheckIO</a></div><div class="ttdeci">CheckIO(NetIO *netio)</div><div class="ttdef"><b>Definition:</b> check_io_channel.h:19</div></div>
<div class="ttc" id="class_check_i_o_html_a45b19f808011f05325614f2efa609175"><div class="ttname"><a href="class_check_i_o.html#a45b19f808011f05325614f2efa609175">CheckIO::netio</a></div><div class="ttdeci">NetIO * netio</div><div class="ttdef"><b>Definition:</b> check_io_channel.h:14</div></div>
<div class="ttc" id="class_check_i_o_html_af1baac326866563f438fa4384b2c10af"><div class="ttname"><a href="class_check_i_o.html#af1baac326866563f438fa4384b2c10af">CheckIO::recv_data_impl</a></div><div class="ttdeci">void recv_data_impl(void *data, int len)</div><div class="ttdef"><b>Definition:</b> check_io_channel.h:37</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_eec959d81771dc8b1a750b834e1341eb.html">emp-tool</a></li><li class="navelem"><a class="el" href="dir_6f7196b439314a1a73bb5510dd78598a.html">io</a></li><li class="navelem"><a class="el" href="check__io__channel_8h.html">check_io_channel.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.12 </li>
  </ul>
</div>
</body>
</html>
